/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.behavioral.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author jmg
 */
public class Main {

    public static void main(String[] args) {

        MyArraryList<String> myArraryList = new MyArraryList<String>();

        myArraryList.add("a");
        myArraryList.add("b");
        myArraryList.add("c");
        myArraryList.add("d");

        Iterator<String> iterator = myArraryList.iterator();

        iterar(iterator);

        MyArraryList2<String> myArraryList2 = new MyArraryList2<String>();

        myArraryList2.add("e");
        myArraryList2.add("f");
        myArraryList2.add("g");
        myArraryList2.add("h");

        iterator = myArraryList2.iterator();

        iterar(iterator);
        
        
        List<String> data = new ArrayList<String>();
        
        data.add("1");
        data.add("2");
        data.add("3");
        data.add("4");
        
        
        java.util.Iterator<String> i = data.iterator();
        
        while(i.hasNext()){
            System.out.println(i.next());
        }
         

    }

    private static void iterar(Iterator<String> iterator) {
        while (iterator.hasNext()) {

            System.out.println(iterator.next());

        }
    }
}
